package com.alibaba.day0318yk.iterator;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @description:
 * @author: Wang
 * @create: 2024-03-18 12:46
 **/
@Component
public class KcIterator implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if (request.getSession().getAttribute("user")!=null){
            return true;
        }
        else {
            response.sendRedirect("/user/toLogin");
            return false;
        }
    }
}
